/**
 * Project Name: socket-test
 * Package Name: com.meatball
 * File Name: WebSocketConfiguration
 * Date: 2021/1/19 23:01
 * User: 張翔宇
 * Copyright (c) 2021, zhang.xiangyu@foxmail.com All Rights Reserved.
 */
package com.meatball;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.web.reactive.HandlerMapping;
import org.springframework.web.reactive.handler.SimpleUrlHandlerMapping;
import org.springframework.web.reactive.socket.WebSocketHandler;
import org.springframework.web.reactive.socket.server.support.WebSocketHandlerAdapter;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 *
 * @title: WebSocketConfiguration.java
 * @author: 張翔宇
 * @date: 2021/1/19 23:01
 * @version: V3.0
 */
@Slf4j
@Configuration
public class WebSocketConfiguration {
    @Bean
    public HandlerMapping webSocketMapping() {
        return new WebSocketMappingHandlerMapping();
    }

    @Bean
    public ConcurrentHashMap<String, WebSocketSender> senderMap() {
        return new ConcurrentHashMap<String, WebSocketSender>(1);
    }


    @Bean
    public WebSocketHandlerAdapter handlerAdapter() {
        return new WebSocketHandlerAdapter();
    }
}
